<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Relations\ValidateTrait;
use App\Models\Relations\CompanyInfoTrait;
use App\Models\Relations\UserInfoTrait;
use App\Models\Relations\AttachmentTrait;
use App\Models\Relations\CategoryTrait;
use App\Models\Relations\CommonTrait;
/**
 *
 * @author Joker
 *        `cat_id` mediumint(8) NOT NULL DEFAULT 0 COMMENT '分类编号',
	`name` varchar(200) NOT NULL COMMENT '标题',
	`description` text NOT NULL COMMENT '简介',
	`tools` text NOT NULL COMMENT '工具',
	`content` longtext NOT NULL COMMENT '步骤  序列化字符串',
	`notice` text DEFAULT NULL COMMENT '注意事项',
	`author` varchar(20) DEFAULT NULL COMMENT '作者',
	`from` char(100) DEFAULT NULL COMMENT '来源',
	`user_id` int(11) NOT NULL COMMENT '创建用户编号',
	`sort` int(10) DEFAULT NULL COMMENT '越大越靠前',
	`teaches_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '充电加油文章类型：0 经验文章；1 ：视频文章 2:ppt文章 默认 0',
	`company_id` int(11) NOT NULL DEFAULT 0 COMMENT '企业编号',
	`is_validate` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否通过审核 1:审核通过；0:未审核；2：审核不通过；默认 0',
	`validated_at` datetime DEFAULT NULL COMMENT '审核时间',
	`is_recommond` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否首页推荐 0 未推荐 1 已推荐',
	`thumb` int(10) NOT NULL DEFAULT 0 COMMENT '封面图片',
	price MEDIUMINT(8) NOT NULL DEFAULT 0 COMMENT '价格 默认为0 免费',
	views_num int(10) NOT NULL DEFAULT 0 COMMENT '浏览人数',
	studys_num int(10) NOT NULL DEFAULT 0 COMMENT '当前学习总人数',
	attention_num int(10) NOT NULL DEFAULT 0 COMMENT '当前课程关注总数',
	comments_num int(10) NOT NULL DEFAULT 0 COMMENT '当前课程评论数',
 */
class TeachesCompany extends Model
{
    use SoftDeletes,ValidateTrait,CompanyInfoTrait,UserInfoTrait,AttachmentTrait,CategoryTrait,CommonTrait;
    
    protected $table="teaches_company";
    
    protected $fillable = ['id','title','cat_id','name','description','tools','content','notice','author','from','user_id','sort',
        'teaches_type','company_id','is_validate','is_recommond','thumb','price','views_num','studys_num','attention_num','comments_num'
    ];
    
    protected $dates = ['deleted_at','validated_at'];
    
    /**
     * 一对一获取 视频信息
     */
    public function office()
    {
        return $this->hasOne('App\Models\TeachesCompanyOffice','tcompany_id','id');
    }
    
    /**
     * 一对一获取 信息
     */
    public function video()
    {
        return $this->hasOne('App\Models\TeachesCompanyVideo','tcompany_id','id');
    }
    
    public function ppt()
    {
        return $this->hasOne('App\Models\TeachesCompanyPpt','tcompany_id','id');
    }
    
    /**
     * 新闻与标签关联表  一对多关联
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function tags()
    {
        return $this->hasMany('App\Models\TeachesCompanyTags','teaches_id','id');
    }
    
}